const Router = require("koa-router");
const home = new Router();
const db = require("../utils/db")

home.get("/",async (ctx)=>{
    ctx.body = "首页"
})

home.get("/banner",async (ctx)=>{
    let mydata= await new Promise((resolve,reject) => {
       return  db.query(`select * from banner`, (err,data)=>{
            if (err) throw err;
            data.map(value => {
                value.img = 'http://locallhost:5000'+value.img;
            })
            // console.log(data)
            resolve(data)
        })
    })

    ctx.body = mydata
})

home.get("/footer",async (ctx)=>{
    ctx.body = "底部"
})

module.exports = home;